<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.wxtf.platform.plugins.user.*"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
	UserBean user = (UserBean)request.getSession().getAttribute("userBean");
	
	String _db = user.getDbType();
	Map<String,List<Map<String, String>>> dicMap = user.getDicMap();
	List<Map<String, String>> list = null;
	String temp = "";
	String tbe_marital_status = "";//婚姻状态
	list = dicMap.get("101");
	list = null;
	list = dicMap.get("27");
	if(null != list && list.size() > 0){
		for(Map<String, String> map: list){
			tbe_marital_status += "<option value=\"" + map.get("tmgd_id")+"\">" + map.get("tmgd_name") + "</option>";
		}
	}
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>人员工作调动</title>
		<base href="<%=basePath%>"/>
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta http-equiv="pragma" content="no-cache"/>
		<meta http-equiv="cache-control" content="no-cache"/>
		<meta http-equiv="expires" content="0"/>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	
		<link type="text/css" rel="stylesheet" href="ligerUI/skins/Aqua/css/ligerui-all.css" />
		<link type="text/css" rel="stylesheet" href="ligerUI/skins/<%=user.getUserCss()%>/css/ligerui-all.css" />
		<link type="text/css" rel="stylesheet" href="ligerUI/skins/ligerui-icons.css" />
		<link type="text/css" rel="stylesheet" href="resource/css/style.css" />
	
		<script type="text/javascript" src="js/jquery/jquery-1.7.2.js"></script>
		<script type="text/javascript" src="ligerUI/js/core/base.js"></script>
		<script type="text/javascript" src="ligerUI/js/ligerui.min.js"></script>
		<script type="text/javascript" src="js/common.js"></script>
		<script type="text/javascript" src="js/validata.js"></script>
	
		<script type="text/javascript" src="ligerUI/js/plugins/ligerGrid.js"></script>
		<script type="text/javascript" src="ligerUI/js/plugins/ligerTree.js"></script>
		
<script type="text/javascript">
var _db = '<%=_db%>';

_jsonObj.classname = "com.wxtf.platform.main.employee.EmpJobMobilityAction";
_jsonObj.methodname = "queryPage";
_jsonObj.logicdata = "[{\"types\":\"init\"}]";

var manager;//人员详细信息显示
var manager_all;//工作调动详细信息的显示
var win3 = null;
var win_do;//调动操作窗口
var win_mob;//调动详细窗口
$(function(){
	manager = $("#emp-job-grid").ligerGrid({
		url: _url, parms: _jsonObj, width: '100%', height: '100%',
		usePager: true, rownumbers: true, checkbox: true, alternatingRow: true,
		columns: [
			{ display: 'tbe_id', name: 'tbe_id', hide: true,width:1 },
			{ display: 'org_id', name: 'org_id', hide: true,width:1 },
			{ display: '机构', name: 'reserve1', width:150, align: 'left'},
			{ display: '姓名', name: 'tbe_name', width: 100, align: 'left',render: function(record, index, value, oth){
					return " <a href='javascript:jobmob(" + JSON.stringify(record) + ")'>"+value+"</a>";
			} },
			{ display: '性别', name: 'tbe_sex', width: 60, align: 'left' },
			{ display: '出生日期', name: 'tbe_birthday', width: 100, align: 'left' },
			{ display: '身份证号', name: 'tbe_idcard', width: 180, align: 'left' },
			{ display: '家庭电话', name: 'tbe_family_phone', width: 100, align: 'left' },
			{ display: '家庭住址', name: 'tbe_address', width: 250, align: 'left' },
			{ display: '婚姻状态', name: 'tbe_marital_status', width: 100, align: 'left',
				render: function(record, index, value, oth){
					<%
					list = dicMap.get("27");
					temp = "";
					if(null != list && list.size() > 0){
						for(Map<String, String> map: list){
					%>
					if(value == '<%=map.get("tmgd_id")%>'){
						<%temp = map.get("tmgd_name");%>
						return '<%=temp%>';
					}
					<%}}%>
					return value;
				}
			},
			{ display: '调动', name:'edit',width:60,isSort:false,render: function(record, index, value, oth){
					return "<img src='ligerUI/skins/icons/edit.gif' onclick='jobmob(" + JSON.stringify(record) + ")'></img>";
				}
			},
			{ display: '明细', name:'show',width:60,isSort:false,render: function(record, index, value, oth){
					return "<img src='ligerUI/skins/icons/edit.gif' onclick='showall(" + JSON.stringify(record) + ")'></img>";
				}
			}
		]
	});	
});
/*
*员工工作调动页面显示
*/
var win_do;//调动操作窗口
function jobmob(row){
	  document.getElementById('job_form').reset();
	  if(win_do==null){
	     win_do=initWindowByDiv('chose_job', '调动表单', 600, 245,save, closeWin);
	  }else{
	     win_do.show();
	  }
	 
	 $("#tbe_id").val(row.tbe_id);
	 $("#tbe_name").val(row.tbe_name); 
	 $("#tbe_sex").val(row.tbe_sex); 
	 $("#original_org_name").val(row.reserve1); 
	 $("#original_org_id").val(row.org_id); 
}

/*
*工作调动操作
**/
function save(){
	var text = document.getElementById('tbejm_type');
	text = text.options[text.selectedIndex].text;
	var teb_id=$("#tbe_id").attr("value");
	var original_org_id=$("#original_org_id").attr("value");
	var current_org_id=$("#current_org_id").attr("value");
	var current_org_name=$("#current_org_name").attr("value");
	var tbejm_reason=$("#tbejm_reason").attr("value").trim();
	var tbejm_type=$("#tbejm_type").val();
	if('1' == tbejm_type && ('' == current_org_name || '' == current_org_id)){
		warningTip('现工作单位：不能为空');
		return;
	}
	
	if('' == tbejm_reason){warningTip("调动原因：不能为空"); return;}
	if(!checkIsString(tbejm_reason)){
		warningTip("调动原因：必须为字母、数字、下划线、中文组成");
		return;
	}
	if(fucCheckLength(tbejm_reason) > 32){
		warningTip("调动原因：不能超过256字符");
		return;
	}
	
	$.ligerDialog.confirm('确定要进行【' + text + '】操作吗？', function (opt) { 			
		if(opt){
			_jsonObj.methodname = "save";
			_jsonObj.logicdata = "[{\"tbe_id\":\"" + teb_id + "\",\"original_org_id\":\""
				+ original_org_id + "\",\"current_org_id\":\"" + current_org_id + "\",\"tbejm_reason\":\""
				+ tbejm_reason + "\",\"tbejm_type\":\"" + tbejm_type + "\",\"current_org_name\":\"" + current_org_name + "\"}]";
			callserver(_jsonObj, ajaxCallbackSuccFunc, ajaxCallbackErrorFunc);
		}
	});
}
/*
*显示员工工作调动信息的窗口
*/
function showall(row){
	if(win_mob==null){
	    win_mob=initWindowByDiv2('job-all-grid', '人员调动历史明细', 790,370,closeWin_);
	}else{
	  win_mob.show();
	}
	var tbe_id=row.tbe_id;
	_jsonObj.methodname = "queryPage_job";
	_jsonObj.logicdata = "[{\"tbe_id\":\""+tbe_id+"\"}]";
	manager_all = $("#job-all-grid").ligerGrid({
		url: _url, parms: _jsonObj, height: '300',
		usePager: true, rownumbers: true, checkbox: false, alternatingRow: true,
		columns: [
			{ display: '原工作单位', name: 'old_org', width: 100, align: 'left' },
			{ display: '现工作单位', name: 'now_org', width: 100, align: 'left' },
			{ display: '调动原因', name: 'tbejm_reason', width: 350, align: 'left' },
			{ display: '调动时间', name:'tbejm_time',width:160,align: 'left'}
		]
	});
}
/*
 * 打开组织机构树
 */
function openOrg(ele){
	var tbejm_type=$("#tbejm_type").val();
	if(tbejm_type != '1'){
		warningTip('现工作单位：无需选择');
		return;
	}
	
	var tree;
	if(win3==null){
		win3 = initWindowByDiv('org-tree-win', '选择机构', 400, 300, function(item, dialog){
			var data = tree.getCheckeds();
			if(data.length == 1){
				$('#current_org_id').val(data[0].data.id);
				$('#current_org_name').val(data[0].data.text);
			} else {
				warningTip('请选择一个机构');
				return;
			}
			
			win3.hide();
		}, closeWin);
		
		tree = $("#org-tree").ligerTree({
			single:true, checkbox: true, nodeWidth: 200,
			url: _url, autoCheckboxEven: false,
			param: {
				"classname": "com.wxtf.platform.plugins.org.OrgAction",
				"methodname": "listOrg4App",
				"logicdata": "[]",
			}
		});
	}else{
		win3.show();
	}
}
//隐藏窗口
function closeWin_(item, dialog) {
	win_mob.hide();
}

/*
 * ajax成功回调
 */
function ajaxCallbackSuccFunc(data, textStatus){
	serch1();
	if(data.result || data.result == 'true'){
		succMsgTip(data.resultrecord);
	}else{
		warningTip(data.resultrecord);
	}
	if(win_do && data.result){
		win_do.hide();
	}
}

/*
 * ajax失败回调
 */
function ajaxCallbackErrorFunc(data, textStatus){
	warningTip(data.resultrecord);
}
/*
 * 条件查询
 */
function serch1(){
	var orgIds = $('#org2').val();
	var tbe_name = $('#ser1').val();
	var tbe_idcard = $('#ser4').val();
	
	_jsonObj.methodname = "queryPage";
	_jsonObj.logicdata = '[{\"orgIds\":\"' + orgIds + '\",\"tbe_name\":\"' + tbe_name
			+ '\",\"tbe_idcard\":\"' + tbe_idcard + '\",\"types\":\"serch1\"}]';
	manager.loadData();
}


</script>
   </head>
   <body>
    <table id="aaa" class="serTable">
		<tr>
			<td>
				机构：<select id="org2" name="org2" style="width: 164px;">
						<%=user.getCurSubOrgOptions()%>
					</select>
			</td>
			<td>姓名：<input id="ser1" style="width: 160px;"/></td>
			<td>身份证：<input id="ser4" style="width: 160px;"/></td>
			<td><input class="btn2" value="搜索" type="button" onclick="serch1();" /></td>
		</tr>
	</table>
	<div id="emp-job-grid"></div>
	<div id="job-all-grid"></div>
	
	<div id="chose_job" style="display: none;">
	   <input type="hidden"  id="tbe_id" name="tbe_id" value=""/>
	   <form id="job_form" name="job_form">
			<input type="hidden" id="original_org_id" name="original_org_id"/>
			<input type="hidden" id="current_org_id" name="current_org_id" />
	      <table class="form_table">
	         <tr>
				<td colspan="6" align="left">
					<div style="border-bottom: 1px solid #EBEBEB; font-weight:bold;height: 28px; line-height: 28px;margin: 0 0 5px;" >
						<img src="ligerUI/skins/icons/communication.gif"/>
						<span>人员调动登记单</span>
					</div>
				</td>
			</tr>
			<tr>
				<td class="form_label">员工姓名：</td>
				<td><input class="textbg1" id="tbe_name" name="tbe_name" readonly="readonly"/></td>
				<td></td>
				<td class="form_label">员工性别：</td>
				<td><input class="textbg1" id="tbe_sex" name="tbe_sex" readonly="readonly" /></td>
				<td></td>
			</tr>
			<tr>
			   <td class="form_label">调动类型：</td>
			   <td><select id="tbejm_type" name="tbejm_type" style=" width: 182px;height:22px">
                     <option value="1">内部调动</option>
                     <option value="2">离职状态</option>
                     <option value="3">死亡状态</option>
			       </select>
			   </td>
			   <td></td>
			</tr>
			<tr>
			   <td class="form_label" style="width:90px">原工作单位：</td>
			   <td><input class="textbg1"  id="original_org_name" name="original_org_name"  readonly="readonly"/></td>
			   <td></td>
			   <td class="form_label" style="width:90px">现工作单位：</td>
			   <td><input class="textbg1" id="current_org_name" name="current_org_name"  onclick="openOrg(this);" readonly="readonly"/></td>
			   <td></td>
			</tr>
			<tr>
			   <td class="form_label">调动原因：</td>
			   <td colspan="4"><textarea class="textbg3"  id="tbejm_reason" name="tbejm_reason" style="height: 60px;width: 455px;" onMouseOver="this.style.borderColor='#4fa8e6'" onMouseOut="this.style.borderColor='#A1A3A1'"></textarea></td>
			   <td align="left"><font color="red">*</font></td>
			</tr>
	      </table>
	   </form>
	</div>	

	<div id="org-tree-win" style="display: none;">
		<div id="org-tree"></div>
	</div>
	
   </body>
</html>